package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyScanInfo;
import com.laowang.project.system.service.MyScanInfoService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 扫码信息Controller
 * 
 * @author laowang
 * @date 2023-09-19
 */
@Api(tags = "扫码信息接口")
@RestController
@RequestMapping("/scanInfo")
public class MyScanInfoController extends BaseController {
    @Autowired
    private MyScanInfoService myScanInfoService;

    @ApiOperation(value = "小程序端 要展示的扫码信息",notes = "")
    @GetMapping("/web")
    public AjaxResult web(Integer id) {

        MyScanInfo myScanInfo = myScanInfoService.selectMyScanInfoById(id);
        return AjaxResult.success("操作成功",myScanInfo);
    }


    /**
     * 查询扫码信息列表
     */
    @ApiOperation(value = "查询扫码信息列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyScanInfo myScanInfo) {
        startPage();
        List<MyScanInfo> list = myScanInfoService.selectMyScanInfoList(myScanInfo);
        return getDataTable(list);
    }
    
    /**
     * 导出扫码信息列表
     */
    @ApiOperation(value = "导出扫码信息列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:export')")
    @Log(title = "扫码信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyScanInfo myScanInfo) {
        List<MyScanInfo> list = myScanInfoService.selectMyScanInfoList(myScanInfo);
        ExcelUtil<MyScanInfo> util = new ExcelUtil<MyScanInfo>(MyScanInfo.class);
        return util.exportExcel(list, "scanInfo");
    }

    /**
     * 获取扫码信息详细信息
     */
    @ApiOperation(value = "获取扫码信息详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myScanInfoService.selectMyScanInfoById(id));
    }

    /**
     * 新增扫码信息
     */
    @ApiOperation(value = "新增扫码信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:add')")
    @Log(title = "扫码信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyScanInfo myScanInfo) {
        return toAjax(myScanInfoService.insertMyScanInfo(myScanInfo));
    }

    /**
     * 修改扫码信息
     */
    @ApiOperation(value = "修改扫码信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:edit')")
    @Log(title = "扫码信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyScanInfo myScanInfo) {
        return toAjax(myScanInfoService.updateMyScanInfo(myScanInfo));
    }

    /**
     * 删除扫码信息
     */
    @ApiOperation(value = "删除扫码信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:scanInfo:remove')")
    @Log(title = "扫码信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myScanInfoService.deleteMyScanInfoByIds(ids));
    }
}
